home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / gfx / show / gs503_data.lha / Ghostscript / data / gs_dps2.ps < prev    next >
Text File  |  1997-08-14  |  7KB  |  206 lines

  1. %    Copyright (C) 1990, 1996, 1997 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % Initialization file for basic Display PostScript functions
  16. % that are also included in Level 2.
  17.  
  18. level2dict begin
  19.  
  20. % ------ Halftones ------ %
  21.  
  22. /.makestackdict
  23.     { { counttomark -1 roll } forall .dicttomark
  24.     } bind def
  25. /currenthalftone        % - currenthalftone <dict>
  26.     { mark .currenthalftone
  27.        { { exch pop }        % halftone
  28.          { /HalftoneType 1        % screen
  29.         { /Frequency /Angle /SpotFunction }
  30.            .makestackdict
  31.          }
  32.          { /HalftoneType 2        % colorscreen
  33.         { /RedFrequency /RedAngle /RedSpotFunction
  34.           /GreenFrequency /GreenAngle /GreenSpotFunction
  35.           /BlueFrequency /BlueAngle /BlueSpotFunction
  36.           /GrayFrequency /GrayAngle /GraySpotFunction
  37.         }
  38.            .makestackdict
  39.          }
  40.        }
  41.       exch get exec
  42.     } odef
  43. % Define sethalftone so it converts all other types to type 5.
  44. /.sethalftoneRGBV    % <dict> <type> <keys> <keysRGBV>
  45.     { 4 -1 roll exch { 1 index exch get exch } forall 15 1 roll
  46.       14 -2 roll mark 15 1 roll { /Gray /Blue /Green /Red }
  47.        {        % stack: v0 v1 v2 type keys comp
  48.          mark
  49.          2 index 0 get 8 -1 roll
  50.          4 index 1 get 9 -1 roll
  51.          6 index 2 get 10 -1 roll
  52.             % stack: type keys comp mark k0 v0 k1 v1 k2 v2
  53.          /HalftoneType 10 index .dicttomark
  54.          counttomark 2 roll
  55.        }
  56.       forall pop pop
  57.       /Default 1 index .dicttomark .sethalftone5
  58.     } bind def
  59. /sethalftone {        % <dict> sethalftone -
  60.         % We must create the new dictionary in the same VM as the
  61.         % operand; otherwise, invalidaccess errors may occur.
  62.     .currentglobal 1 index dup gcheck .setglobal
  63.     dup /HalftoneType get 1 sub {
  64.           { mark /Default 2 index .dicttomark .sethalftone5
  65.           }
  66.           { 1 { /Frequency /Angle /SpotFunction }
  67.         { /RedFrequency /RedAngle /RedSpotFunction
  68.           /GreenFrequency /GreenAngle /GreenSpotFunction
  69.           /BlueFrequency /BlueAngle /BlueSpotFunction
  70.           /GrayFrequency /GrayAngle /GraySpotFunction
  71.         } .sethalftoneRGBV
  72.           }
  73.           { mark /Default 2 index .dicttomark .sethalftone5
  74.           }
  75.           { 3 { /Width /Height /Thresholds }
  76.         { /RedWidth /RedHeight /RedThresholds
  77.           /GreenWidth /GreenHeight /GreenThresholds
  78.           /BlueWidth /BlueHeight /BlueThresholds
  79.           /GrayWidth /GrayHeight /GrayThresholds
  80.         } .sethalftoneRGBV
  81.           }
  82.           { dup .sethalftone5
  83.           }
  84.     } exch get exec .setglobal pop
  85. } odef
  86. % Redefine setscreen and setcolorscreen to recognize halftone dictionaries,
  87. % and to insert the Frequency and Angle into Type 1 halftones, per
  88. % Adobe TN 5085.
  89. /.fixsethalftonescreen        % <freq> <angle> <dict> .fix...screen
  90.                 %   <freq> <angle> <dict> <dict'>
  91.  { dup dup /HalftoneType get 1 eq
  92.     { dup wcheck not { dup length .copydict } if
  93.       dup /Frequency 5 index put
  94.       dup /Angle 4 index put
  95.     }
  96.    if
  97.  } bind def
  98. /setscreen        % <ignore*2> <dict> setscreen -
  99.     { dup type /dicttype eq
  100.        { .fixsethalftonescreen sethalftone pop pop pop }
  101.        { //setscreen }
  102.       ifelse
  103.     } odef
  104. /setcolorscreen        % <ignore*11> <dict> setcolorscreen -
  105.     { dup type /dicttype eq
  106.        { .fixsethalftonescreen sethalftone 12 { pop } repeat }
  107.        { //setcolorscreen }
  108.       ifelse
  109.     } odef
  110. % Redefine currentscreen and currentcolorscreen to extract the Frequency
  111. % and Angle from Type 1 halftones, per Adobe TN 5085.
  112. /.fixcurrenthalftonescreen    % <dict> .fix... <freq> <angle> <proc>
  113.  { dup /HalftoneType get 1 eq
  114.     { dup /Frequency get 1 index /Angle get }
  115.     { 60 0 }
  116.    ifelse 3 2 roll
  117.  } bind def
  118. /currentscreen        % - currentscreen 60 0 <dict>
  119.     { .currenthalftone
  120.        { { .fixcurrenthalftonescreen }    % halftone
  121.          { }                % screen
  122.          { 12 3 roll 9 { pop } repeat    % colorscreen
  123.            dup type /dicttype eq { .fixcurrenthalftonescreen } if
  124.          }
  125.        }
  126.       exch get exec
  127.     } odef
  128. /currentcolorscreen    % - currentcolorscreen (60 0 <dict>)*4
  129.     { .currenthalftone
  130.        { { .fixcurrenthalftonescreen 3 copy 6 copy }    % halftone
  131.          { 3 copy 6 copy }            % screen
  132.          { }                % colorscreen
  133.        }
  134.       exch get exec
  135.     } odef
  136.  
  137. % ------ User objects ------ %
  138.  
  139. /.localarray where {
  140.   pop
  141. } {
  142.   /.localarray {
  143.     currentglobal false setglobal
  144.     exch array exch setglobal
  145.   } bind def
  146. } ifelse
  147. % The name UserObjects may be rebound, but we need to make sure these
  148. % operators always refer to the binding in userdict (which may also be
  149. % rebound!).
  150. /.UserObjects {
  151.   //systemdict /userdict get /UserObjects
  152. } odef
  153. % In order to get proper error recovery behavior, we need to be careful
  154. % not to pop any operands from the stack until we're done.
  155. % The code below faithfully duplicates the apparent array-growing
  156. % behavior of Adobe interpreters.
  157. /defineuserobject {        % <index> <value> defineuserobject -
  158.   .UserObjects .knownget {
  159.     length dup 3 index le {
  160.         % Stack: index value len
  161.       2 index eq { 1 index 2 mul } { 1 index 1 add } ifelse
  162.       .localarray userdict /UserObjects get
  163.       1 index copy pop
  164.       .UserObjects 3 -1 roll put
  165.     } {
  166.       pop
  167.     } ifelse
  168.   } {
  169.     .UserObjects 3 index 1 add 10 .max .localarray put
  170.   } ifelse
  171.   .UserObjects get 2 index 2 index put pop pop
  172. } odef
  173. /execuserobject {        % <index> execuserobject -
  174.   .UserObjects get 1 index get exch pop exec
  175. } odef
  176. /undefineuserobject {        % <index> undefineuserobject -
  177.   .UserObjects get 1 index null put pop
  178. } odef
  179.  
  180. % ------ User paths ------ %
  181.  
  182. % We define upath carefully so it won't leave garbage on the stack
  183. % if an error occurs.
  184. /upath {            % <bool> upath <array>
  185.     [ 1 index {/ucache cvx} if
  186.     true .pathbbox /setbbox cvx
  187.      {/moveto cvx} {/lineto cvx} {/curveto cvx} {/closepath cvx}
  188.     pathforall ] cvx exch pop
  189. } odef
  190.  
  191. % Dummy definitions for cache control operators
  192.  
  193. /ucachestatus {            % - ucachestatus -mark- ? ? ? ? <size>
  194.     mark 0 0 0 0 userdict /.ucachesize .knownget not { 0 } if
  195. } odef
  196. /setucacheparams {        % -mark- ... <size> setucacheparams -
  197.         % Provoke an appropriate error if needed.
  198.     counttomark 1 lt { () 0 get } if
  199.     0 or userdict /.ucachesize 2 index 0 .max put cleartomark
  200. } odef
  201.  
  202. end                % level2dict
  203.